import React, { Component } from "react";
// import qs from "querystring";

const DetailsData = [
  { id: "01", content: "01" },
  { id: "02", content: "02" },
  { id: "03", content: "03" },
];
export default class Details extends Component {
  render() {
    /*接收params参数
     * const { id, title } = this.props.match.params;
     */

    /* 接收search参数
     *const { search } = this.props.location;
     *const { id, title } = qs.parse(search.slice(1));
     */

    /*接收state参数 */
    const { id, title } = this.props.location.state || {};
    const findResult =
      DetailsData.find((detailsObj) => {
        return detailsObj.id === id;
      }) || {};
    return (
      <div>
        <div>{id}</div>
        <div>{title}</div>
        <div>{findResult.content}</div>
      </div>
    );
  }
}
